//
//  UIColor+YS.m
//  luGongPro
//
//  Created by 王庆学 on 2017/7/31.
//  Copyright © 2017年 王庆学. All rights reserved.
//

#import "UIColor+YS.h"
#import "YSDefines.h"

@implementation UIColor (YS)

- (NSArray *)rgbaArray
{
    CGFloat r=0,g=0,b=0,a=0;
    if ([self respondsToSelector:@selector(getRed:green:blue:alpha:getRed:green:blue:alpha:)]){
        [self getRed:&r green:&g blue:&b alpha:&a];
    }else{
        const CGFloat *components = CGColorGetComponents(self.CGColor);
        r = components[0];
        g = components[1];
        b = components[2];
        a = components[3];
    }
    return @[@(r),
             @(g),
             @(b),
             @(a)];
}

+ (UIColor *)bullColor{
    return [UIColor colorFromHexString:@"#f5463a"];
}

+ (UIColor *)bearColor{
    return [UIColor colorFromHexString:@"#11bc65"];
}

+ (UIColor *)defaultColor{
    return [UIColor colorFromHexString:@"#2b2f33"];
}

+ (UIColor *)transparentColor{
    return [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
}

+ (UIColor *)tabBarTitleColor{
    return [UIColor colorFromHexString:@"#969fa9"];
}

+ (UIColor *)fontLightColor{
    return [UIColor colorFromHexString:@"#969fa9"];
}

+ (UIColor *)fontDarkColor{
    return [UIColor colorFromHexString:@"#464c56"];
}

/** 底部栏默认背景 */
+ (UIColor *)tabBarBackgroundColor
{
    return [UIColor colorFromHexString:@"#DC143C"];
}

/** 底部栏选中字体颜色 */
+ (UIColor *)tabBarSelectTitleColor
{
    return [UIColor colorFromHexString:@"#023e97"];
}

/** 顶部导航栏的颜色 */
+ (UIColor *)navigationBarColor
{
    return [UIColor colorFromHexString:@"#183e97"];
}

/** 页面背景的颜色 */
+ (UIColor *)viewBackColor
{
    return [UIColor colorFromHexString:@"#F1F6F5"];
}

+ (UIColor *)chartBullColor
{
    return [UIColor colorFromHexString:@"#ed333b"];
}

+ (UIColor *)chartBearColor
{
    return [UIColor colorFromHexString:@"#17b03e"];
}

+ (UIColor *)chartDefaultColor
{
    return [UIColor colorFromHexString:@"#464c56"];
}

+ (UIColor *)lightBackgroudColor
{
    return UIColorWithHex(0xEEEEEE);
}

+ (UIColor *)quotationDefaultColor
{
    return [UIColor colorFromHexString:@"#898989"];
}

+ (UIColor *)lightBackgroundColor
{
    return [UIColor colorFromHexString:@"#f4f4f4"];
}

+ (UIImage *)imageWithSolidColor:(UIColor *)color size:(CGSize)size{
    CGRect rect = CGRectMake(0.0f, 0.0f, size.width, size.height);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}

@end
